<template>
  <div>
    <h3>前7天销量</h3>
    <div class="main"></div>
  </div>
</template>

<script>
export default {
  mounted() {
    this.zhutu();
  },
  methods: {
    zhutu() {
      let arrdata = [];
      let createDate = this.$moment();
      createDate.format("MM/DD");
      arrdata.push(createDate.add(-7, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      arrdata.push(createDate.add(1, "d").format("MM/DD"));
      //.format("MM/DD");

      console.log(createDate);
      console.log(arrdata);
      let chartDom = document.querySelector(".main");
      let myChart = this.$echarts.init(chartDom);

      let option = {
        xAxis: {
          type: "category",
          data: [...arrdata],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [120, 70, 150, 80, 200, 110, 130],
            type: "bar",
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
};
</script>

<style lang="scss" scoped>
.main {
  height: 400px;
  width: 500px;
}
</style>
